<?php


abstract class BaseTblDistributorPeer {

	
	const DATABASE_NAME = 'propel';

	
	const TABLE_NAME = 'tbl_distributor';

	
	const CLASS_DEFAULT = 'lib.model.TblDistributor';

	
	const NUM_COLUMNS = 47;

	
	const NUM_LAZY_LOAD_COLUMNS = 0;


	
	const F_ID = 'tbl_distributor.F_ID';

	
	const F_CODE = 'tbl_distributor.F_CODE';

	
	const F_USER_ID = 'tbl_distributor.F_USER_ID';

	
	const F_NAME = 'tbl_distributor.F_NAME';

	
	const F_NICKNAME = 'tbl_distributor.F_NICKNAME';

	
	const F_IC = 'tbl_distributor.F_IC';

	
	const F_COUNTRY = 'tbl_distributor.F_COUNTRY';

	
	const F_ADDRESS = 'tbl_distributor.F_ADDRESS';

	
	const F_POSTCODE = 'tbl_distributor.F_POSTCODE';

	
	const F_EMAIL = 'tbl_distributor.F_EMAIL';

	
	const F_CONTACT = 'tbl_distributor.F_CONTACT';

	
	const F_GENDER = 'tbl_distributor.F_GENDER';

	
	const F_DOB = 'tbl_distributor.F_DOB';

	
	const F_BANK_NAME = 'tbl_distributor.F_BANK_NAME';

	
	const F_BANK_ACC_NO = 'tbl_distributor.F_BANK_ACC_NO';

	
	const F_BANK_HOLDER_NAME = 'tbl_distributor.F_BANK_HOLDER_NAME';

	
	const F_PARENTID = 'tbl_distributor.F_PARENTID';

	
	const F_LEFT = 'tbl_distributor.F_LEFT';

	
	const F_RIGHT = 'tbl_distributor.F_RIGHT';

	
	const F_LEVEL = 'tbl_distributor.F_LEVEL';

	
	const F_PARENTID2 = 'tbl_distributor.F_PARENTID2';

	
	const F_LEFT2 = 'tbl_distributor.F_LEFT2';

	
	const F_RIGHT2 = 'tbl_distributor.F_RIGHT2';

	
	const F_LEG2 = 'tbl_distributor.F_LEG2';

	
	const F_LEVEL2 = 'tbl_distributor.F_LEVEL2';

	
	const F_PLACEMENT_DATETIME = 'tbl_distributor.F_PLACEMENT_DATETIME';

	
	const F_STATUS = 'tbl_distributor.F_STATUS';

	
	const F_GAP = 'tbl_distributor.F_GAP';

	
	const F_GAP_DATETIME = 'tbl_distributor.F_GAP_DATETIME';

	
	const F_ACTIVE_DATETIME = 'tbl_distributor.F_ACTIVE_DATETIME';

	
	const F_CREATED_BY = 'tbl_distributor.F_CREATED_BY';

	
	const F_CREATED_DATETIME = 'tbl_distributor.F_CREATED_DATETIME';

	
	const PARENT_ID = 'tbl_distributor.PARENT_ID';

	
	const PARENT_CODE = 'tbl_distributor.PARENT_CODE';

	
	const TOTAL_LEFT = 'tbl_distributor.TOTAL_LEFT';

	
	const TOTAL_RIGHT = 'tbl_distributor.TOTAL_RIGHT';

	
	const TREE_LEVEL = 'tbl_distributor.TREE_LEVEL';

	
	const TREE_STRUCTURE = 'tbl_distributor.TREE_STRUCTURE';

	
	const UPLINE_DIST_ID = 'tbl_distributor.UPLINE_DIST_ID';

	
	const UPLINE_DIST_CODE = 'tbl_distributor.UPLINE_DIST_CODE';

	
	const PLACEMENT_POSITION = 'tbl_distributor.PLACEMENT_POSITION';

	
	const PLACEMENT_DATETIME = 'tbl_distributor.PLACEMENT_DATETIME';

	
	const ACTIVE_DATETIME = 'tbl_distributor.ACTIVE_DATETIME';

	
	const RANK_ID = 'tbl_distributor.RANK_ID';

	
	const RANK_CODE = 'tbl_distributor.RANK_CODE';

	
	const INIT_RANK_ID = 'tbl_distributor.INIT_RANK_ID';

	
	const INIT_RANK_CODE = 'tbl_distributor.INIT_RANK_CODE';

	
	private static $phpNameMap = null;


	
	private static $fieldNames = array (
		BasePeer::TYPE_PHPNAME => array ('FId', 'FCode', 'FUserId', 'FName', 'FNickname', 'FIc', 'FCountry', 'FAddress', 'FPostcode', 'FEmail', 'FContact', 'FGender', 'FDob', 'FBankName', 'FBankAccNo', 'FBankHolderName', 'FParentid', 'FLeft', 'FRight', 'FLevel', 'FParentid2', 'FLeft2', 'FRight2', 'FLeg2', 'FLevel2', 'FPlacementDatetime', 'FStatus', 'FGap', 'FGapDatetime', 'FActiveDatetime', 'FCreatedBy', 'FCreatedDatetime', 'ParentId', 'ParentCode', 'TotalLeft', 'TotalRight', 'TreeLevel', 'TreeStructure', 'UplineDistId', 'UplineDistCode', 'PlacementPosition', 'PlacementDatetime', 'ActiveDatetime', 'RankId', 'RankCode', 'InitRankId', 'InitRankCode', ),
		BasePeer::TYPE_COLNAME => array (TblDistributorPeer::F_ID, TblDistributorPeer::F_CODE, TblDistributorPeer::F_USER_ID, TblDistributorPeer::F_NAME, TblDistributorPeer::F_NICKNAME, TblDistributorPeer::F_IC, TblDistributorPeer::F_COUNTRY, TblDistributorPeer::F_ADDRESS, TblDistributorPeer::F_POSTCODE, TblDistributorPeer::F_EMAIL, TblDistributorPeer::F_CONTACT, TblDistributorPeer::F_GENDER, TblDistributorPeer::F_DOB, TblDistributorPeer::F_BANK_NAME, TblDistributorPeer::F_BANK_ACC_NO, TblDistributorPeer::F_BANK_HOLDER_NAME, TblDistributorPeer::F_PARENTID, TblDistributorPeer::F_LEFT, TblDistributorPeer::F_RIGHT, TblDistributorPeer::F_LEVEL, TblDistributorPeer::F_PARENTID2, TblDistributorPeer::F_LEFT2, TblDistributorPeer::F_RIGHT2, TblDistributorPeer::F_LEG2, TblDistributorPeer::F_LEVEL2, TblDistributorPeer::F_PLACEMENT_DATETIME, TblDistributorPeer::F_STATUS, TblDistributorPeer::F_GAP, TblDistributorPeer::F_GAP_DATETIME, TblDistributorPeer::F_ACTIVE_DATETIME, TblDistributorPeer::F_CREATED_BY, TblDistributorPeer::F_CREATED_DATETIME, TblDistributorPeer::PARENT_ID, TblDistributorPeer::PARENT_CODE, TblDistributorPeer::TOTAL_LEFT, TblDistributorPeer::TOTAL_RIGHT, TblDistributorPeer::TREE_LEVEL, TblDistributorPeer::TREE_STRUCTURE, TblDistributorPeer::UPLINE_DIST_ID, TblDistributorPeer::UPLINE_DIST_CODE, TblDistributorPeer::PLACEMENT_POSITION, TblDistributorPeer::PLACEMENT_DATETIME, TblDistributorPeer::ACTIVE_DATETIME, TblDistributorPeer::RANK_ID, TblDistributorPeer::RANK_CODE, TblDistributorPeer::INIT_RANK_ID, TblDistributorPeer::INIT_RANK_CODE, ),
		BasePeer::TYPE_FIELDNAME => array ('f_id', 'f_code', 'f_user_id', 'f_name', 'f_nickname', 'f_ic', 'f_country', 'f_address', 'f_postcode', 'f_email', 'f_contact', 'f_gender', 'f_dob', 'f_bank_name', 'f_bank_acc_no', 'f_bank_holder_name', 'f_parentid', 'f_left', 'f_right', 'f_level', 'f_parentid2', 'f_left2', 'f_right2', 'f_leg2', 'f_level2', 'f_placement_datetime', 'f_status', 'f_gap', 'f_gap_datetime', 'f_active_datetime', 'f_created_by', 'f_created_datetime', 'parent_id', 'parent_code', 'total_left', 'total_right', 'tree_level', 'tree_structure', 'upline_dist_id', 'upline_dist_code', 'placement_position', 'placement_datetime', 'active_datetime', 'rank_id', 'rank_code', 'init_rank_id', 'init_rank_code', ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, )
	);

	
	private static $fieldKeys = array (
		BasePeer::TYPE_PHPNAME => array ('FId' => 0, 'FCode' => 1, 'FUserId' => 2, 'FName' => 3, 'FNickname' => 4, 'FIc' => 5, 'FCountry' => 6, 'FAddress' => 7, 'FPostcode' => 8, 'FEmail' => 9, 'FContact' => 10, 'FGender' => 11, 'FDob' => 12, 'FBankName' => 13, 'FBankAccNo' => 14, 'FBankHolderName' => 15, 'FParentid' => 16, 'FLeft' => 17, 'FRight' => 18, 'FLevel' => 19, 'FParentid2' => 20, 'FLeft2' => 21, 'FRight2' => 22, 'FLeg2' => 23, 'FLevel2' => 24, 'FPlacementDatetime' => 25, 'FStatus' => 26, 'FGap' => 27, 'FGapDatetime' => 28, 'FActiveDatetime' => 29, 'FCreatedBy' => 30, 'FCreatedDatetime' => 31, 'ParentId' => 32, 'ParentCode' => 33, 'TotalLeft' => 34, 'TotalRight' => 35, 'TreeLevel' => 36, 'TreeStructure' => 37, 'UplineDistId' => 38, 'UplineDistCode' => 39, 'PlacementPosition' => 40, 'PlacementDatetime' => 41, 'ActiveDatetime' => 42, 'RankId' => 43, 'RankCode' => 44, 'InitRankId' => 45, 'InitRankCode' => 46, ),
		BasePeer::TYPE_COLNAME => array (TblDistributorPeer::F_ID => 0, TblDistributorPeer::F_CODE => 1, TblDistributorPeer::F_USER_ID => 2, TblDistributorPeer::F_NAME => 3, TblDistributorPeer::F_NICKNAME => 4, TblDistributorPeer::F_IC => 5, TblDistributorPeer::F_COUNTRY => 6, TblDistributorPeer::F_ADDRESS => 7, TblDistributorPeer::F_POSTCODE => 8, TblDistributorPeer::F_EMAIL => 9, TblDistributorPeer::F_CONTACT => 10, TblDistributorPeer::F_GENDER => 11, TblDistributorPeer::F_DOB => 12, TblDistributorPeer::F_BANK_NAME => 13, TblDistributorPeer::F_BANK_ACC_NO => 14, TblDistributorPeer::F_BANK_HOLDER_NAME => 15, TblDistributorPeer::F_PARENTID => 16, TblDistributorPeer::F_LEFT => 17, TblDistributorPeer::F_RIGHT => 18, TblDistributorPeer::F_LEVEL => 19, TblDistributorPeer::F_PARENTID2 => 20, TblDistributorPeer::F_LEFT2 => 21, TblDistributorPeer::F_RIGHT2 => 22, TblDistributorPeer::F_LEG2 => 23, TblDistributorPeer::F_LEVEL2 => 24, TblDistributorPeer::F_PLACEMENT_DATETIME => 25, TblDistributorPeer::F_STATUS => 26, TblDistributorPeer::F_GAP => 27, TblDistributorPeer::F_GAP_DATETIME => 28, TblDistributorPeer::F_ACTIVE_DATETIME => 29, TblDistributorPeer::F_CREATED_BY => 30, TblDistributorPeer::F_CREATED_DATETIME => 31, TblDistributorPeer::PARENT_ID => 32, TblDistributorPeer::PARENT_CODE => 33, TblDistributorPeer::TOTAL_LEFT => 34, TblDistributorPeer::TOTAL_RIGHT => 35, TblDistributorPeer::TREE_LEVEL => 36, TblDistributorPeer::TREE_STRUCTURE => 37, TblDistributorPeer::UPLINE_DIST_ID => 38, TblDistributorPeer::UPLINE_DIST_CODE => 39, TblDistributorPeer::PLACEMENT_POSITION => 40, TblDistributorPeer::PLACEMENT_DATETIME => 41, TblDistributorPeer::ACTIVE_DATETIME => 42, TblDistributorPeer::RANK_ID => 43, TblDistributorPeer::RANK_CODE => 44, TblDistributorPeer::INIT_RANK_ID => 45, TblDistributorPeer::INIT_RANK_CODE => 46, ),
		BasePeer::TYPE_FIELDNAME => array ('f_id' => 0, 'f_code' => 1, 'f_user_id' => 2, 'f_name' => 3, 'f_nickname' => 4, 'f_ic' => 5, 'f_country' => 6, 'f_address' => 7, 'f_postcode' => 8, 'f_email' => 9, 'f_contact' => 10, 'f_gender' => 11, 'f_dob' => 12, 'f_bank_name' => 13, 'f_bank_acc_no' => 14, 'f_bank_holder_name' => 15, 'f_parentid' => 16, 'f_left' => 17, 'f_right' => 18, 'f_level' => 19, 'f_parentid2' => 20, 'f_left2' => 21, 'f_right2' => 22, 'f_leg2' => 23, 'f_level2' => 24, 'f_placement_datetime' => 25, 'f_status' => 26, 'f_gap' => 27, 'f_gap_datetime' => 28, 'f_active_datetime' => 29, 'f_created_by' => 30, 'f_created_datetime' => 31, 'parent_id' => 32, 'parent_code' => 33, 'total_left' => 34, 'total_right' => 35, 'tree_level' => 36, 'tree_structure' => 37, 'upline_dist_id' => 38, 'upline_dist_code' => 39, 'placement_position' => 40, 'placement_datetime' => 41, 'active_datetime' => 42, 'rank_id' => 43, 'rank_code' => 44, 'init_rank_id' => 45, 'init_rank_code' => 46, ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, )
	);

	
	public static function getMapBuilder()
	{
		include_once 'lib/model/map/TblDistributorMapBuilder.php';
		return BasePeer::getMapBuilder('lib.model.map.TblDistributorMapBuilder');
	}
	
	public static function getPhpNameMap()
	{
		if (self::$phpNameMap === null) {
			$map = TblDistributorPeer::getTableMap();
			$columns = $map->getColumns();
			$nameMap = array();
			foreach ($columns as $column) {
				$nameMap[$column->getPhpName()] = $column->getColumnName();
			}
			self::$phpNameMap = $nameMap;
		}
		return self::$phpNameMap;
	}
	
	static public function translateFieldName($name, $fromType, $toType)
	{
		$toNames = self::getFieldNames($toType);
		$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
		if ($key === null) {
			throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
		}
		return $toNames[$key];
	}

	

	static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
	{
		if (!array_key_exists($type, self::$fieldNames)) {
			throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
		}
		return self::$fieldNames[$type];
	}

	
	public static function alias($alias, $column)
	{
		return str_replace(TblDistributorPeer::TABLE_NAME.'.', $alias.'.', $column);
	}

	
	public static function addSelectColumns(Criteria $criteria)
	{

		$criteria->addSelectColumn(TblDistributorPeer::F_ID);

		$criteria->addSelectColumn(TblDistributorPeer::F_CODE);

		$criteria->addSelectColumn(TblDistributorPeer::F_USER_ID);

		$criteria->addSelectColumn(TblDistributorPeer::F_NAME);

		$criteria->addSelectColumn(TblDistributorPeer::F_NICKNAME);

		$criteria->addSelectColumn(TblDistributorPeer::F_IC);

		$criteria->addSelectColumn(TblDistributorPeer::F_COUNTRY);

		$criteria->addSelectColumn(TblDistributorPeer::F_ADDRESS);

		$criteria->addSelectColumn(TblDistributorPeer::F_POSTCODE);

		$criteria->addSelectColumn(TblDistributorPeer::F_EMAIL);

		$criteria->addSelectColumn(TblDistributorPeer::F_CONTACT);

		$criteria->addSelectColumn(TblDistributorPeer::F_GENDER);

		$criteria->addSelectColumn(TblDistributorPeer::F_DOB);

		$criteria->addSelectColumn(TblDistributorPeer::F_BANK_NAME);

		$criteria->addSelectColumn(TblDistributorPeer::F_BANK_ACC_NO);

		$criteria->addSelectColumn(TblDistributorPeer::F_BANK_HOLDER_NAME);

		$criteria->addSelectColumn(TblDistributorPeer::F_PARENTID);

		$criteria->addSelectColumn(TblDistributorPeer::F_LEFT);

		$criteria->addSelectColumn(TblDistributorPeer::F_RIGHT);

		$criteria->addSelectColumn(TblDistributorPeer::F_LEVEL);

		$criteria->addSelectColumn(TblDistributorPeer::F_PARENTID2);

		$criteria->addSelectColumn(TblDistributorPeer::F_LEFT2);

		$criteria->addSelectColumn(TblDistributorPeer::F_RIGHT2);

		$criteria->addSelectColumn(TblDistributorPeer::F_LEG2);

		$criteria->addSelectColumn(TblDistributorPeer::F_LEVEL2);

		$criteria->addSelectColumn(TblDistributorPeer::F_PLACEMENT_DATETIME);

		$criteria->addSelectColumn(TblDistributorPeer::F_STATUS);

		$criteria->addSelectColumn(TblDistributorPeer::F_GAP);

		$criteria->addSelectColumn(TblDistributorPeer::F_GAP_DATETIME);

		$criteria->addSelectColumn(TblDistributorPeer::F_ACTIVE_DATETIME);

		$criteria->addSelectColumn(TblDistributorPeer::F_CREATED_BY);

		$criteria->addSelectColumn(TblDistributorPeer::F_CREATED_DATETIME);

		$criteria->addSelectColumn(TblDistributorPeer::PARENT_ID);

		$criteria->addSelectColumn(TblDistributorPeer::PARENT_CODE);

		$criteria->addSelectColumn(TblDistributorPeer::TOTAL_LEFT);

		$criteria->addSelectColumn(TblDistributorPeer::TOTAL_RIGHT);

		$criteria->addSelectColumn(TblDistributorPeer::TREE_LEVEL);

		$criteria->addSelectColumn(TblDistributorPeer::TREE_STRUCTURE);

		$criteria->addSelectColumn(TblDistributorPeer::UPLINE_DIST_ID);

		$criteria->addSelectColumn(TblDistributorPeer::UPLINE_DIST_CODE);

		$criteria->addSelectColumn(TblDistributorPeer::PLACEMENT_POSITION);

		$criteria->addSelectColumn(TblDistributorPeer::PLACEMENT_DATETIME);

		$criteria->addSelectColumn(TblDistributorPeer::ACTIVE_DATETIME);

		$criteria->addSelectColumn(TblDistributorPeer::RANK_ID);

		$criteria->addSelectColumn(TblDistributorPeer::RANK_CODE);

		$criteria->addSelectColumn(TblDistributorPeer::INIT_RANK_ID);

		$criteria->addSelectColumn(TblDistributorPeer::INIT_RANK_CODE);

	}

	const COUNT = 'COUNT(tbl_distributor.F_ID)';
	const COUNT_DISTINCT = 'COUNT(DISTINCT tbl_distributor.F_ID)';

	
	public static function doCount(Criteria $criteria, $distinct = false, $con = null)
	{
		
		$criteria = clone $criteria;

		
		$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(TblDistributorPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(TblDistributorPeer::COUNT);
		}

		
		foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$rs = TblDistributorPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
			
			return 0;
		}
	}
	
	public static function doSelectOne(Criteria $criteria, $con = null)
	{
		$critcopy = clone $criteria;
		$critcopy->setLimit(1);
		$objects = TblDistributorPeer::doSelect($critcopy, $con);
		if ($objects) {
			return $objects[0];
		}
		return null;
	}
	
	public static function doSelect(Criteria $criteria, $con = null)
	{
		return TblDistributorPeer::populateObjects(TblDistributorPeer::doSelectRS($criteria, $con));
	}
	
	public static function doSelectRS(Criteria $criteria, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if (!$criteria->getSelectColumns()) {
			$criteria = clone $criteria;
			TblDistributorPeer::addSelectColumns($criteria);
		}

		
		$criteria->setDbName(self::DATABASE_NAME);

		
		
		return BasePeer::doSelect($criteria, $con);
	}
	
	public static function populateObjects(ResultSet $rs)
	{
		$results = array();
	
		
		$cls = TblDistributorPeer::getOMClass();
		$cls = Propel::import($cls);
		
		while($rs->next()) {
		
			$obj = new $cls();
			$obj->hydrate($rs);
			$results[] = $obj;
			
		}
		return $results;
	}
	
	public static function getTableMap()
	{
		return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
	}

	
	public static function getOMClass()
	{
		return TblDistributorPeer::CLASS_DEFAULT;
	}

	
	public static function doInsert($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 
		} else {
			$criteria = $values->buildCriteria(); 
		}

		$criteria->remove(TblDistributorPeer::F_ID); 


		
		$criteria->setDbName(self::DATABASE_NAME);

		try {
			
			
			$con->begin();
			$pk = BasePeer::doInsert($criteria, $con);
			$con->commit();
		} catch(PropelException $e) {
			$con->rollback();
			throw $e;
		}

		return $pk;
	}

	
	public static function doUpdate($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$selectCriteria = new Criteria(self::DATABASE_NAME);

		if ($values instanceof Criteria) {
			$criteria = clone $values; 

			$comparison = $criteria->getComparison(TblDistributorPeer::F_ID);
			$selectCriteria->add(TblDistributorPeer::F_ID, $criteria->remove(TblDistributorPeer::F_ID), $comparison);

		} else { 
			$criteria = $values->buildCriteria(); 
			$selectCriteria = $values->buildPkeyCriteria(); 
		}

		
		$criteria->setDbName(self::DATABASE_NAME);

		return BasePeer::doUpdate($selectCriteria, $criteria, $con);
	}

	
	public static function doDeleteAll($con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}
		$affectedRows = 0; 
		try {
			
			
			$con->begin();
			$affectedRows += BasePeer::doDeleteAll(TblDistributorPeer::TABLE_NAME, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	 public static function doDelete($values, $con = null)
	 {
		if ($con === null) {
			$con = Propel::getConnection(TblDistributorPeer::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 
		} elseif ($values instanceof TblDistributor) {

			$criteria = $values->buildPkeyCriteria();
		} else {
			
			$criteria = new Criteria(self::DATABASE_NAME);
			$criteria->add(TblDistributorPeer::F_ID, (array) $values, Criteria::IN);
		}

		
		$criteria->setDbName(self::DATABASE_NAME);

		$affectedRows = 0; 

		try {
			
			
			$con->begin();
			
			$affectedRows += BasePeer::doDelete($criteria, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public static function doValidate(TblDistributor $obj, $cols = null)
	{
		$columns = array();

		if ($cols) {
			$dbMap = Propel::getDatabaseMap(TblDistributorPeer::DATABASE_NAME);
			$tableMap = $dbMap->getTable(TblDistributorPeer::TABLE_NAME);

			if (! is_array($cols)) {
				$cols = array($cols);
			}

			foreach($cols as $colName) {
				if ($tableMap->containsColumn($colName)) {
					$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
					$columns[$colName] = $obj->$get();
				}
			}
		} else {

		}

		return BasePeer::doValidate(TblDistributorPeer::DATABASE_NAME, TblDistributorPeer::TABLE_NAME, $columns);
	}

	
	public static function retrieveByPK($pk, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$criteria = new Criteria(TblDistributorPeer::DATABASE_NAME);

		$criteria->add(TblDistributorPeer::F_ID, $pk);


		$v = TblDistributorPeer::doSelect($criteria, $con);

		return !empty($v) > 0 ? $v[0] : null;
	}

	
	public static function retrieveByPKs($pks, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$objs = null;
		if (empty($pks)) {
			$objs = array();
		} else {
			$criteria = new Criteria();
			$criteria->add(TblDistributorPeer::F_ID, $pks, Criteria::IN);
			$objs = TblDistributorPeer::doSelect($criteria, $con);
		}
		return $objs;
	}

} 


if (Propel::isInit()) {
	
	
	try {
		BaseTblDistributorPeer::getMapBuilder();
	} catch (Exception $e) {
		Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
	}
} else {
	
	
	require_once 'lib/model/map/TblDistributorMapBuilder.php';
	Propel::registerMapBuilder('lib.model.map.TblDistributorMapBuilder');
}
